import java.util.Scanner;

public class HJ55 {
    public static void main(String[] args) {
        //挑7
        Scanner sc = new Scanner(System.in);
        int target = sc.nextInt();
        int count = 0;
        for (int i = target; i>=1; i--){
            if(i%7==0){
                count++;
            }else if(String.valueOf(i).contains("7")){
                count++;
            }
        }
        System.out.println(count);
    }
}
